package com.mdinfo.gw.door.doorDriver.aopu.request;

import com.mdinfo.base.utils.StringUtil;
import lombok.Data;
import org.apache.commons.lang3.time.FastDateFormat;

import java.util.Date;

/**
 * Created by Administrator on 2018/2/5.
 * 新增开放时间
 */
@Data
public class OpenTimeAddReq extends BaseReq{

    private String startTime;
    private String endTime;
    private String week;
    private String opMode;
    private String endDate;

    public OpenTimeAddReq(Integer mjno,String startTime,String endTime,String week,int mode,Date end){
        this.setCmd("addOpenTime");
        this.setTrace(StringUtil.getUUid());
        this.setTimeStamp(new Date().getTime());
        this.setMjno(mjno);
        this.setDrno(0);
        this.startTime = startTime.replaceAll(":","").substring(0,4);
        this.endTime = endTime.replaceAll(":","").substring(0,4);
        this.week = week.replaceAll(",","");
        FastDateFormat format = FastDateFormat.getInstance("yyMMdd");
        this.endDate = format.format(end);
        if(mode==1){
            this.opMode = "00000001";
        }else if(mode==2){
            this.opMode = "00000010";
        }else if(mode==3){
            this.opMode = "00000100";
        }else if(mode==4){
            this.opMode = "00001000";
        }else if(mode==5){
            this.opMode = "00010000";
        }else if(mode==6){
            this.opMode = "00100000";
        }else if(mode==7){
            this.opMode = "01000000";
        }else if(mode==8){
            this.opMode = "10000000";
        }
    }
}
